package com.yutel.phone.binh.data;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

public class BinhConfig {
	private static final String SEARCHHOST = "searchhost";
	private static final String SERVERHOST = "serverhost";
	private static final String UPDATE = "update";
	private static final String IMAGECACHE = "imagecache";
	private static SharedPreferences spf;
	public static final int SearchPort = 5405;
	public static final String app = "/epg/";
	public static final String updateFile = "updateinfo.txt";
	public static final String videosPath = "videos/";
	public static final String channelFile = "/channels-categories.xml";
	public static final String recommendFile = "/recommend-channels-categories.xml";
	// 变量
	public static String searchHost;
	public static String serverHost;
	public static String update;
	public static boolean imageCache;

	public BinhConfig(Context context) {
		spf = PreferenceManager.getDefaultSharedPreferences(context);
		init();
	}

	public static void setSearchHost(String searchHost) {
		BinhConfig.searchHost = searchHost;
		Editor editor = spf.edit();
		editor.putString(SEARCHHOST, searchHost);
		editor.commit();
	}

	public static void setServerHost(String serverHost) {
		BinhConfig.serverHost = serverHost;
		Editor editor = spf.edit();
		editor.putString(SERVERHOST, serverHost);
		editor.commit();
	}
	public static void setUpdate(String update) {
		BinhConfig.update = update;
		Editor editor = spf.edit();
		editor.putString(UPDATE, update);
		editor.commit();
	}
	public static void setImageCache(boolean imageCache) {
		BinhConfig.imageCache = imageCache;
		Editor editor = spf.edit();
		editor.putBoolean(IMAGECACHE, imageCache);
		editor.commit();
	}
	private void init() {
		searchHost = spf.getString(SEARCHHOST, "192.168.3.239");
		serverHost = spf.getString(SERVERHOST, "192.168.2.243");
		update = spf.getString(UPDATE, "");
		imageCache =spf.getBoolean(IMAGECACHE, true);
	}

}
